package com.hspedu.newData.dmsxl.数学技巧;

import org.junit.Test;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-28 
 * @Version: 1.0
 */

public class LC136只出现一次的数字 {

    public int singleNumber(int[] nums) {

        if (nums.length == 1) return nums[0];
        int res = nums[0];
        for (int i = 1; i < nums.length; i++) {
            res = res^nums[i];
        }

        return res;
    }


    @Test
    public void test() {
        // 测试代码
        singleNumber(new int[]{2,1,2});
    }
}
